# #Lagos download script
#LAGOSNE::lagosne_get(dest_folder = LAGOSNE:::lagos_path())
#Load in lagos
lagos <- lagosne_load()
#Grab the lake centroid info
lake_centers <- lagos$locus
#Look at the column names
#names(lake_centers)
#Look at the structure
#str(lake_centers)
#View the full dataset
#View(lake_centers %>% slice(1:100))
spatial_lakes <- st_as_sf(lake_centers,coords=c('nhd_long','nhd_lat'),
crs=4326) %>%
st_transform(2163)
#Subset for plotting
subset_spatial <- spatial_lakes %>%
slice(1:100)
subset_baser <- spatial_lakes[1:100,]
#Dynamic mapviewer
mapview(subset_spatial)
states <- us_states()
#Plot all the states to check if they loaded
#mapview(states)
minnesota <- states %>%
filter(name == 'Minnesota') %>%
st_transform(2163)
#Subset lakes based on spatial position
minnesota_lakes <- spatial_lakes[minnesota,]
#Plotting the first 1000 lakes
minnesota_lakes %>%
arrange(-lake_area_ha) %>%
slice(1:1000) %>%
mapview(.,zcol = 'lake_area_ha')
IA_IL <- states %>%
filter(name == "Iowa" | name == "Illinois") %>%
st_transform(2163)
mapview(IA_IL)
IA_IL_lakes <- spatial_lakes[IA_IL,]
count(IA_IL_lakes)
## Simple feature collection with 1 feature and 1 field
## Geometry type: MULTIPOINT
## Dimension: XY
## Bounding box: xmin: 277299.3 ymin: -824038.9 xmax: 1080254 ymax: -128993.5
## Projected CRS: NAD27 / US National Atlas Equal Area
## n geometry
## 1 16466 MULTIPOINT ((277299.3 -2468...
There are 16466 sites in Iowa and Illinois combined, which is a little more that half the sites in Minnesota alone.
Q3 <- spatial_lakes %>% filter(state_zoneid == "State_14" | state_zoneid == "State_13") %>%
mutate(state = ifelse(state_zoneid == "State_14", paste("Minnesota"), paste("Iowa")))
ggplot(Q3, aes(lake_area_ha))+
geom_histogram(bins = 4) +
# scale_x_continuous(breaks = seq(0, 130000, 4))
facet_wrap(~state)
max(Q3$lake_area_ha)
## [1] 123779.8
The majority of lakes in both states are under 25,000 acres. Minnesota has many more lakes.
IA_IL_lakes %>%
arrange(-lake_area_ha) %>%
mapview(.,zcol = 'lake_area_ha')